//
//  SEGMenuCommunityViewController.m
//  SEGHelenFort
//
//  Created by 乔杨 on 2019/8/29.
//  Copyright © 2019 山刘. All rights reserved.
//

#import "SEGMenuCommunityViewController.h"

@interface SEGMenuCommunityViewController ()

@end

@implementation SEGMenuCommunityViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self segIsSign];
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    // 判断是否显示活动抽奖气泡 必须放在viewDidAppear里，否则有可能判断当前界面的时候失败
    [self seg_checkActivityLotteryBubble];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[SEGUhomeMediator sharedInstance] seg_hiddenActivitySignBubble:nil];
    [[SEGUhomeMediator sharedInstance] seg_hiddenActivityLotteryBubble:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kColor_W;
    self.navigationItem.title = @"邻里社区";
//    self.tableView.frame = CGRectMake(0,
//                                      0,
//                                      LYScreenWidth(),
//                                      LYScreenHeight()-LYNavigationBarAndStatusBarHeight()-49-LYSafeAreaBottom());
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.equalTo(self.view);
    }];
    // 收到活动抽奖推送
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(seg_checkActivityLotteryBubble)
                                                 name:SEGActivityLotteryNotification
                                               object:nil];
    WeakSelf;
    [self.tableView addWindmillWithHeaderRefreshBlock:^{
        // 刷新网络菜单数据
        [weakSelf segShowLocalDataAndRequestServerDataIsManualRefresh:YES];
    }];
}

#pragma mark - 抽奖气泡
// 判断是否显示活动抽奖气泡
- (void)seg_checkActivityLotteryBubble {
    [[SEGUhomeMediator sharedInstance] seg_checkActivityLotteryBubble:@{@"vc" : self}];
}

#pragma mark - 签到气泡
//请求活动签到气泡是否显示
- (void)segIsSign {
    [[SEGUhomeMediator sharedInstance] seg_checkActivitySignBubble:@{@"nav" : self.navigationController, @"view" : self.view}];
}

@end
